//
//  IMPDFSignature.h
//  IMSecurity
//
//  Created by infosec2013 on 2017/12/22.
//  Copyright © 2017年 IF. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "IMUser.h"
#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger,PDFSigantureStamperType){
    PDFSigantureStamperCompany = 1, //公章
    PDFSigantureStamperContract, //合同章
    PDFSigantureStamperFinancial, //财务章
    PDFSigantureStamperPersonal
};

@class IMPDFSignature;


typedef void (^PDFCompletionBlock)(NSString *desc);

@interface IMPDFSignature : NSObject
- (instancetype)initWithUser:(IMUser *)user error:(int *)error;

/**
 对本地PDF文件进行签章
 
 @param filePath 本地pdf文件路径
 @param page 签章页面
 @param pos 签章位置
 @param certPIN 证书PIN码
 @param reason 签章原因
 @param completionBlock 完成后执行block
 */
- (void)signLocalPDFWithFilePath:(NSString *)filePath
                            page:(int)page
                           atPos:(NSValue *)pos
                         certPIN:(NSString *)certPIN
                          reason:(NSString *)reason
                 completionBlock:(void(^)(int resultCode,NSString *signedPDFUrl))completionBlock;

/**
 对在线PDF文件进行签章
 
 @param identifier 在线pdf文件对应ID
 @param page 签章页面
 @param pos 签章位置
 @param certPIN 证书PIN码
 @param reason 签章原因
 @param completionBlock 完成后执行block
 */
- (void)signCloudPDFWithIdentifier:(NSString *)identifier
                          page:(int)page
                         atPos:(NSValue *)pos
                       certPIN:(NSString *)certPIN
                        reason:(NSString *)reason
               completionBlock:(void(^)(int resultCode,NSString *signedPDFUrl))completionBlock;


/// 获取在线PDF文件下载路径
/// @param identifier 在线pdf文件对应ID
/// @param business 业务标识
/// @param block 完成后执行block
- (void)getPDFFileURLWithIdentifier:(NSString *)identifier
                           business:(NSString *)business
                    completionBlock:(void(^)(NSString *pdfURL,int resultCode))block;

/**
 获取签章
 
 @param completionBlock 完成后block
 */
- (void)getSignatureStamperWithCompletionBlock:(void(^)(int resultCode,NSString *stamperUrl))completionBlock;

/**
 注册签章图片

 @param stamperImage 签章图片内容
 @param certPIN 证书PIN码
 @param stamperType 签章类型
 @param block 完成后执行block
 */
- (void)registStamperWithImage:(UIImage *)stamperImage
                       certPIN:(NSString *)certPIN
                   stamperType:(PDFSigantureStamperType)stamperType
               completionBlock:(void(^)(int resultCode))block;


/// 更新签章图片
/// @param stamperImage 签章图片内容
/// @param certPIN 证书PIN码
/// @param block 完成后执行block
- (void)updateStamperWithImage:(UIImage *)stamperImage
                       certPIN:(NSString *)certPIN
               completionBlock:(void(^)(int resultCode))block;

- (void)verifyPDFSignatureWithFile:(NSString *)filePath
                   completionBlock:(void(^)(int resultCode))block;


@end

